#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 1e5 + 10;

int e[N], ne[N], h[N], idx;
int n, m;
int res, level;

void add(int a, int b) {
    e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void BFS() {
    queue<int> q;
    q.push(1);
    int le = 1;
    while (q.size()) {
        int n = q.size();
        if (n > res) res = n, level = le;
        for (int i = 1; i <= n; i ++ ) {
            int head = q.front(); q.pop();
            for (int j = h[head]; j != -1; j = ne[j]) {
                int k = e[j];
                q.push(k);
            }
        }
        le ++ ;
    }
}

// 构树 BFS层序遍历 看每一层有多少个Node
inline void solution() {
    mm(h, -1);
    cin >> n >> m;
    for (int i = 0; i < m; i ++ ) {
        int parent, cnt;
        cin >> parent >> cnt;
        while (cnt -- ) {
            int child;
            cin >> child;
            add(parent, child);
        }
    }
    BFS();
    cout << res << " " << level << endl;
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}